package com.systop.asset.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;

import com.systop.asset.entity.Inventory;
import com.systop.asset.entity.RestResponse;
import com.systop.asset.service.IInventoryService;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;


/**
 * 耗材库存Controller
 * 
 * @author mu
 * @date 2025-07-04
 */
@RestController
@RequestMapping("/asset/inventory")
public class InventoryController {
    @Autowired
    private IInventoryService inventoryService;

    /**
     * 查询库存列表
     */
    @GetMapping("/list")
    public RestResponse list(Inventory inventory)
    {
        List<Inventory> list = inventoryService.selectInventoryList(inventory);
        return RestResponse.success(list);
    }


    @GetMapping("/assetCheckList")
    public RestResponse assetCheckList(Inventory inventory)
    {
        List<Inventory> list = inventoryService.selectInventoryList(inventory);
        return RestResponse.success(list);
    }
    /**
     * 获取库存详细信息
     */
    @PreAuthorize("@ss.hasPermi('inventory:inventory:query')")
    @GetMapping(value = "/{id}")
    public RestResponse getInfo(@PathVariable("id") Long id)
    {
        return RestResponse.success(inventoryService.selectInventoryById(id));
    }

    /**
     * 新增库存
     */
    @PostMapping
    public RestResponse add(@RequestBody Inventory inventory)
    {
        return RestResponse.success(inventoryService.insertInventory(inventory));
    }

    /**
     * 修改库存
     */
    @PutMapping
    public RestResponse edit(@RequestBody Inventory inventory)
    {
        return RestResponse.success(inventoryService.updateInventory(inventory));
    }

    /**
     * 删除库存
     */
	@DeleteMapping("/{ids}")
    public RestResponse remove(@PathVariable Long[] ids)
    {
        return RestResponse.success(inventoryService.deleteInventoryByIds(ids));
    }
}
